<?php
require_once realpath(dirname(__FILE__) . '//..//pages.php');
require_once CLASS_DATABASE;
require_once INC_DEFINES;
require_once INC_FUNCTIONS;

$db = openConnection();

/*doesn't work!*/
function backup () {
    $folder = $root . '/backups/'. date ("Y-m-d") . '/';
    if ($db->backup ($folder)) {
        return true;
    }
    return false;
}

/**
 * This method deletes records in the database
 * 
 * @param string $table name of the table
 * @param string $where [Optional] condition
 * @return boolean true on success or false on error
 */
function delete ($table, $where = null) {
    return $db->delete($table, $where);
}

/**
 * This method inserts records into the database
 * 
 * @param string $table name of the table
 * @param array $values associative array that must contain values associated with a key that corresponds with the name of its field
 * @return boolean true on success or false on error
 */
function insert ($table, $values) {
    return $db->insert($table, $values);
}

function select ($tables, $fields = null, $where = null, $group_by = null, $order_by = null, $limit = null) {
    return $db->select($tables, $fields, $where, $group_by, $order_by, $limit);
}

function update ($tables, $values, $where = null) {
    return $db->update($tables, $values, $where);
}
?>
